package com.ysu.his.admin.controller;

import com.ysu.his.admin.service.SchedulingService;
import com.ysu.his.dto.DoctorScheduleDto;
import com.ysu.his.vo.DoctorScheduleVo;
import com.ysu.his.vo.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/api/admin/scheduling")
public class SchedulingController
{
    @Autowired
    private SchedulingService schedulingService;

    @GetMapping(value = "/getSchedulingByDoctorId/{doctorId}/{scheduleDate}")
    public Result getSchedulingByPage(@PathVariable("doctorId") Long doctorId,
                                      @PathVariable("scheduleDate") String scheduleDate)
    {
        DoctorScheduleVo doctorScheduleVo = schedulingService.getSchedulingByDoctorId(doctorId,scheduleDate);
        return Result.ok(doctorScheduleVo);
    }

    @PostMapping(value = "/addOrUpdateScheduling")
    public Result addOrUpdateScheduling(@RequestBody DoctorScheduleDto doctorScheduleDto)
    {
        schedulingService.addOrUpdateScheduling(doctorScheduleDto);
        return Result.ok(null);
    }


    @GetMapping(value = "/cancel/{id}")
    public Result cancel(@PathVariable("id") Long id)
    {
        schedulingService.cancelSchedule(id);
        return Result.ok(null);
    }
}
